<template>
    <div class=" zy-content ">
      <div class="searchBox search-box-layout">
        <Row :gutter="24">
          <Col span="4">
            <div>
              <p class="label">{{$t('common.company')}}</p>
              <div class="ipt">
                <Select v-model="searchParams.companyId" filterable clearable :placeholder="`${$t('common.selectInfo')}`"
                        @on-change="getBackupList($event, 1)">
                  <Option v-for="(item) of companyList" :value="item.id" :key="item.code" :label="item.fullName"></Option>
                </Select>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('preliminary.PurchasingOrderNumber')}}</p>
              <div class="ipt">
                <Input type="text" v-model="searchParams.purchaseOrderNo" clearable :placeholder="`${$t('common.inputInfo')}`"
                       :maxlength="32"></Input>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.Warehouse')}}</p>
              <div class="ipt">
                <Select v-model="searchParams.warehouseId" filterable clearable :placeholder="`${$t('common.selectInfo')}`">
                  <Option v-for="(item) of searchBackupList" :value="item.id" :key="item.id" :label="item.backupName">
                  </Option>
                </Select>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.ContractNo')}}</p>
              <div class="ipt">
                <Input type="text" v-model="searchParams.contractNo" clearable :placeholder="`${$t('common.inputInfo')}`"
                       :maxlength="32"></Input>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.PartNo')}}</p>
              <div class="ipt">
                <Select v-model="searchParams.materielNo" :remote-method="getMaterielsList" clearable filterable :placeholder="`${$t('common.selectInfo')}`">
                  <Option v-for="item in materielsList" :value="item.materielNo" :key="item.id"
                          :label="item.materielNo" />
                </Select>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.SparePartABC')}}</p>
              <div class="ipt">
                <Select v-model="searchParams.sparePartsABC" filterable clearable :placeholder="`${$t('common.selectInfo')}`">
                  <Option v-for="(item) of sparePartsAbcList" :value="item.value" :key="item.value" :label="item.label"></Option>
                </Select>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.SparePartVED')}}</p>
              <div class="ipt">
                <Select v-model="searchParams.sparePartsVED" filterable clearable :placeholder="`${$t('common.selectInfo')}`">
                  <Option v-for="(item) of sparePartsVedList" :value="item.value" :key="item.value" :label="item.label"></Option>
                </Select>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.Name')}}</p>
              <div class="ipt">
                <Input type="text" v-model="searchParams.goodsName" clearable :placeholder="`${$t('common.inputInfo')}`"
                       :maxlength="32"></Input>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('preliminary.OrderingDate')}}</p>
              <div class="ipt">
                <DatePicker @on-change="timeOnChange" :value="searchParams.dateVal" format="yyyy-MM-dd HH:mm:ss"
                            type="datetimerange" :placeholder="`${$t('common.selectInfo')}`" clearable></DatePicker>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.Specification')}}</p>
              <div class="ipt">
                <Input type="text" v-model="searchParams.specification" clearable :placeholder="`${$t('common.inputInfo')}`"
                       :maxlength="32"></Input>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.OrderStatus')}}</p>
              <div class="ipt">
                <Select v-model="searchParams.orderStatus" filterable clearable :placeholder="`${$t('common.selectInfo')}`">
                  <Option v-for="(item) of orderStatus" :value="item.label" :key="item.label">
                    {{ item.value }}</Option>
                </Select>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label">{{$t('spareParts.ControlMode')}}</p>
              <div class="ipt">
                <Select v-model="searchParams.manageType" filterable clearable :placeholder="`${$t('common.selectInfo')}`">
                  <Option v-for="(item) of manageType" :value="item.value" :key="item.value" :label="item.label"></Option>
                </Select>
              </div>
            </div>
          </Col>
          <Col span="4">
            <div>
              <p class="label hide-label">--</p>
              <div class="ipt">
                <Button class="search-btn" type="primary" v-if="checkBtnPermission.purchaseList"
                        @click="changeNum()">{{ $t('common.Query') }}</Button>
                <Button class="reset-btn" @click="reset()"
                        v-if="checkBtnPermission.purchaseList"
                >{{ $t('common.reset') }}
                </Button>
              </div>
            </div>
          </Col>
        </Row>
      </div>
       <div class="list-layout mt16">
         <div class="btns clear">

           <span class="title">{{ $t('common.listInformation') }}</span>
           <Button  @click="handelAdd" v-if="checkBtnPermission.purchaseAdd">{{ $t('common.New') }}</Button>
           <Button  @click="delFaultCodeShowClick" v-if="checkBtnPermission.purchaseDelete">{{ $t('common.batchDelete')}}</Button>
           <Button  @click="exportTemplateClick" v-if="checkBtnPermission.purchaseExport">{{ $t('common.batchExport') }}</Button>
           <Button  @click="importExcelShow" v-if="checkBtnPermission.purchaseImport">{{ $t('common.Import') }}</Button>
           <Button  @click="exportTemplate" v-if="checkBtnPermission.purchaseTemplate">{{ $t('common.Download') }}</Button>
             <Button @click="getTableColumns(columns)">
                 {{ handleContextMenuStatus ? $t('显示操作栏') : $t('隐藏操作栏') }}
             </Button>
         </div>
         <div class="tableContent">
           <Table class="resizable-table" border @on-column-width-resize="onColumnWidthResize"
                  :columns="columnsList" ellipsis ref="selection" stripe  :data="dataArr"
                  @on-selection-change="onSelectChange">

             <template slot-scope="{ row }" slot="action">
               <!-- 入库 -->
               <span class="operationBtn" @click="lockClick(row)"
                     v-if="checkBtnPermission.purchaseGetInfo"><i class="iconfont zy-common-chakan"></i>{{ $t('common.Check') }}</span>
               <span class="operationBtn" @click="createfaultCodeShowH(row)"
                     v-if="checkBtnPermission.beputinstorageAdd && row.orderStatus != '1'"><i class="iconfont zy-common-neirong"></i>{{ $t('spareParts.Putaway') }}</span>
               <span class="operationBtn" @click="delPrrShowH(row)"
                     v-if="checkBtnPermission.purchaseDelete && row.orderStatus != '1'"><i class="iconfont zy-common-shanchu"></i>{{ $t('common.Delete') }}</span>
               <!-- 删除 -->
             </template>
           </Table>
         </div>
         <div class="pageWrap">
           <Page :total="total" :page-size="pageSize" :page-size-opts="pageSizeOption" :current="pageNum"
                 @on-change="changePageNum" @on-page-size-change="changePageSize" show-sizer show-total />
         </div>
       </div>
        <!-- 入库 -->
        <Modal :mask-closable="false" v-model="create" :title="addtitle" width="900" class="modal-content-layout">
            <div class="createModal">
                <div class="tableContent">
                    <Row style="padding: 0 0 20px 0;line-height: 40px;font-size: 14px;">
                        <Col span="16">
                        <!-- 订单总数： -->
                        <span class="pr">📜{{ $t('spareParts.OrderQuantity') }}: <strong>{{ formItem.purchaseCount }}</strong>; </span>
                        <!-- 已入库数量 -->
                        <span class="pr">🏭{{ $t('spareParts.InStorage') }}: <strong>{{ formItem.amountOfReceived }}</strong>; </span>
                        <!-- 待入库数量 -->
                        <span class="pr">🚚{{ $t('spareParts.ToBeStored') }}: <strong>{{ formItem.amountOfToBeReceived }}</strong></span>
                        </Col>
                        <Col span="8" style="text-align: right">
<!--                        <div @click="handleAdd">-->
<!--                            <Icon type="ios-add-circle-outline" size="16" />-->
<!--                            &lt;!&ndash; 添加入库信息 &ndash;&gt;-->
<!--                            <span>{{ $t('spareParts.ToBeStored') }}</span>-->
<!--                        </div>-->
                          <Button class="ivu-btn-lg" @click="handleAdd">{{ $t('spareParts.Putaway') }}</Button>
                        </Col>
                    </Row>
                    <Table class="resizable-table table" border @on-column-width-resize="(a,b,c,d)=>{onColumnWidthResize(a,b,c,d,'attachmentProcurementProcurement')}"
                         ellipsis stripe :columns="infoColumns" :data="infoDataArr" > </Table>
                    <Page :total="totalModel" :page-size="pageSizeModel" :page-size-opts="pageSizeOptionModel"
                        :current="pageNumModel" @on-change="changePageNumModel"
                        @on-page-size-change="changePageSizeModel" show-sizer show-total style="margin-bottom:40px" />
                </div>
                <!-- :rules="ruleValidate" -->
                <Form ref="form" :model="procurementAddList" label-position="top">
                    <div class="addContenrt">
                        <row :gutter="16" v-for="(val, index) in procurementAddList" :key="index">
                            <Col span="5">
                            <!-- 仓库 -->
                            <FormItem prop="user" :label="$t('spareParts.Warehouse')">
                                <Select v-model="val.backupConfigId" filterable clearable disabled :placeholder="`${$t('common.selectInfo')}`">
                                    <Option v-for="(item) of backupList" :value="item.id" :key="item.id">{{item.backupName}}</Option>
                                </Select>
                            </FormItem>
                            </Col>
                            <Col span="5">
                            <!-- 货架 -->
                            <FormItem prop="user" :label="$t('spareParts.Rack')">
                                <Select v-model="val.shelfId" filterable clearable :placeholder="`${$t('common.selectInfo')}`"
                                    @on-change="getLocationList(val.shelfId, index)">
                                    <Option v-for="(item) of shelfList" :value="item.id" :key="item.id" :label="item.shelf"></Option>
                                </Select>
                            </FormItem>
                            </Col>
                            <Col span="5">
                            <!-- 库位 -->
                            <FormItem prop="user" :label="$t('spareParts.Location')">
                                <Select v-model="val.locationId" filterable clearable :placeholder="`${$t('common.selectInfo')}`">
                                    <Option v-for="(item) of locationList[index].list" :value="item.id" :key="item.id"  :label="item.location">
                                    </Option>
                                </Select>
                            </FormItem>
                            </Col>
                            <Col span="5">
                            <!-- 入库数量 -->
                            <FormItem prop="user" :label="$t('spareParts.NumberOfStorage')">
                                <Input type="number" v-model="val.inputCount" :maxlength="11" :placeholder="`${$t('common.inputInfo')}`" />
                            </FormItem>
                            </Col>

<!--                          <Col span="4">-->
<!--                            &lt;!&ndash; 资产编号 &ndash;&gt;-->
<!--                            <FormItem prop="user" :label="$t('ledger.AssetNo')">-->
<!--                              <Input-->
<!--                                     v-model="val.assetsNo" :maxlength="32"-->
<!--                                     @on-change="assetsNochange(val)"-->
<!--                                     :placeholder="`${$t('common.inputInfo')}`" />-->
<!--                            </FormItem>-->
<!--                          </Col>-->
                            <Col span="4">
                            <FormItem prop="">
                                <Icon type="ios-trash-outline" @click="handleDelete(index)" size="20"
                                    style="color:red;line-height: 69px;cursor: pointer;" />
                            </FormItem>
                            </Col>
                        </row>
                    </div>
                </Form>
            </div>
            <div slot="footer">
                <!-- 删除 -->
                <Button type="default" @click="create = false">{{ $t('common.Cancle') }}</Button>
                <!-- 确认 -->
                <Button type="primary" :loading="loading"
                    @click="addOk('form')">{{ $t('maintenance.Confirmed') }}</Button>
            </div>

        </Modal>
        <Modal :mask-closable="false" v-model="delFaultCodeShowF"  :title="$t('common.Delete')"
               class="modal-title-layout">
          <div class="icon red">
            <i class="iconfont zy-common-shanchu"></i>
          </div>
          <p class="title">
            <span>{{$t('common.confirmDelete')}}</span>
          </p>
            <div slot="footer">
                <Button type="default" @click="delFaultCodeShowF = false">{{ $t('common.Cancle') }}</Button>
                <Button type="primary" :loading="loading" @click="deleteOk">{{ $t('maintenance.Confirmed') }}</Button>
            </div>
        </Modal>
        <!-- 新增 -->
        <Modal :mask-closable="false" v-model="addModel" class="addModel modal-content-layout" :title="addtitle" width="600px" @on-cancel="cancel" >
            <Form ref="addForm" class="formList" :model="formAddObj" :rules="ruleValidate" label-position="top" inline>
                <Row>
                    <Col span="10">
                    <!-- 合同编号： -->
                    <FormItem :label="$t('spareParts.ContractNo')" prop="contractNo">
                        <Input type="text" v-model="formAddObj.contractNo" :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 采购订单号： -->
                    <FormItem :label="$t('preliminary.PurchasingOrderNumber')" prop="purchaseOrderNo">
                        <Input type="text" v-model="formAddObj.purchaseOrderNo" :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <!-- 公司名称： -->
                    <FormItem :label="$t('spareParts.company')" prop="companyId">
                        <Select v-model="formAddObj.companyId" filterable clearable :placeholder="`${$t('common.selectInfo')}`"
                            @on-change="getBackupList($event, 2)">
                            <Option v-for="(item) of companyList" :value="item.id" :key="item.code">{{ item.fullName }}</Option>
                        </Select>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 仓库： -->
                    <FormItem :label="$t('spareParts.Warehouse')" prop="warehouseId">
                        <Select v-model="formAddObj.warehouseId" filterable clearable :placeholder="`${$t('common.selectInfo')}`">
                            <Option v-for="(item) of addBackupList" :value="item.id" :key="item.id">{{ item.backupName }}</Option>
                        </Select>
                    </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <!-- 料号： -->
                    <FormItem :label="$t('common.PartNo')" prop="materielNo">
                        <Select v-model="formAddObj.materielNo" :remote-method="getQueryMaterielsList" clearable filterable :placeholder="`${$t('common.selectInfo')}`"
                            @on-change="handleChange($event)">
                            <Option v-for="item in queryMaterielsList" :value="item.materielNo" :key="item.id"
                                :label="item.materielNo" />
                        </Select>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 品名： -->
                    <FormItem :label="$t('spareParts.Name')">
                        <Input type="text" v-model="addObj.goodsName" disabled :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <!-- 规格： -->
                    <FormItem :label="$t('spareParts.Specification')">
                        <Input type="text" v-model="addObj.specification" disabled :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 备件ABC类 -->
                    <FormItem :label="$t('spareParts.SparePartABC')">
                        <Input type="text" v-model="addObj.sparePartsABC" disabled :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <!-- 备件VED类 -->
                    <FormItem :label="$t('spareParts.SparePartVED')">
                        <Input type="text" v-model="addObj.sparePartsVED" disabled :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 物品分类： -->
                    <FormItem :label="$t('spareParts.ObjectClassification')">
                        <Input type="text" v-model="addObj.goodsTypeStr" disabled :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <!-- 资产类型： -->
                    <FormItem :label="$t('spareParts.AssetType')">
                        <Input type="text" v-model="addObj.assetTypeStr" disabled :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 管理方式： -->
                    <FormItem :label="$t('spareParts.ControlMode')">
                        <Input type="text" v-model="addObj.manageTypeStr" disabled :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></Input>
                    </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <!-- 采购数量： -->
                    <FormItem :label="$t('spareParts.PurchasingQuantity')" prop="purchaseCount">
                        <InputNumber v-model="formAddObj.purchaseCount"
                                     :placeholder="`${$t('common.inputInfo')}`"
                                     @on-change="purchaseCountChange"
                            :autosize="{ minRows: 2, maxRows: 5 }"></InputNumber>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 采购单价： -->
                    <FormItem :label="$t('common.UnitPrice')" prop="purchasePrice">
                        <InputNumber v-model="formAddObj.purchasePrice"
                                     @on-change="purchasePriceChange"
                                     :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></InputNumber>
                    </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <!-- 采购总价： -->
                    <FormItem :label="$t('common.GrossPrice')" prop="purchaseAmount">
                        <InputNumber v-model="formAddObj.purchaseAmount"
                                     disabled
                                     :placeholder="`${$t('common.inputInfo')}`"
                            :autosize="{ minRows: 2, maxRows: 5 }"></InputNumber>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 下单日期： -->
                    <FormItem :label="$t('preliminary.OrderingDate')">
                        <DatePicker type="datetime" :placeholder="`${$t('common.selectInfo')}`" v-model="formAddObj.purchaseDate"
                            format="yyyy-MM-dd HH:mm:ss"></DatePicker>
                    </FormItem>

                    </Col>
                </Row>
                <Row>
                    <Col span="10">
                    <!-- 采购人员： -->
                    <FormItem :label="$t('spareParts.ProcurementStaff')" prop="purchasingAgent">
                        <Select v-model="formAddObj.purchasingAgent"
                                filterable clearable :placeholder="`${$t('common.inputInfo')}`">
                            <Option v-for="(item, index) of createByOptions" :value="item.id" :key="index">{{item.showName}}</Option>
                        </Select>
                    </FormItem>
                    </Col>
                    <Col span="10" offset="4">
                    <!-- 采购合同： -->
                    <FormItem :label="$t('维修单号')">
                      <Input type="text" v-model="formAddObj.workOrderNo" :placeholder="`${$t('common.inputInfo')}`"></Input>
                    </FormItem>
                    </Col>
                </Row>
              <Row>
                <Col span="10">
                  <!-- 到位日期： -->
                  <FormItem :label="$t('到位日期')" >
                    <DatePicker type="datetime" :placeholder="`${$t('common.selectInfo')}`" v-model="formAddObj.arrivalDate"
                                format="yyyy-MM-dd HH:mm:ss"></DatePicker>
                  </FormItem>
                </Col>
                <Col span="10" offset="4">
                  <!-- 采购合同： -->
                  <FormItem :label="$t('preliminary.PurchasingContract')">
                    <Upload ref="fileUpload" :show-upload-list="false" :before-upload="handleBeforeUpload"
                            type="drag" action="" style="width:95px">
                      <!-- 点击上传 -->
                      <Button type="primary">{{ $t('common.Upload') }}</Button>
                    </Upload>

                    <div class="file-list" v-for="(item, index) in setFileList" :key="index">
                      <span class="item-src" @click="handlePreview(item)">{{ item.fileName }}</span>
                      <Icon class="item-icon" type="ios-trash-outline" size="20" @click="delFileList(index)"
                            v-if="item"></Icon>
                    </div>
                  </FormItem>
                </Col>
              </Row>
            </Form>
            <div slot="footer">
                <Button type="default" @click="cancel">{{ $t('common.Cancle') }}</Button>
                <Button type="primary" :loading="loading"
                    @click="addYes('addForm')">{{ $t('maintenance.Confirmed') }}</Button>
            </div>
        </Modal>
        <importExcelModal :importExcelStateF="importExcelState" v-if="importExcelState"
            @importExcelChange="importExcelChange"></importExcelModal>
    </div>
</template>

<script>
import moment from 'moment';
import { searchApi, addApi, enterApi, deleteApi, templateApi, exportApi, infoBeputinstorageApi } from "@/api/spareParts/procurement.js";
import { getUserSelect, getCompany, getBackup, getShelf, getLocation, getMateriels } from "@/api/index.js";
import importExcelModal from '@/components/importExcel.vue';
import fileDownload from 'js-file-download';
import toggleTableOperation from "@/mixins/toggleTableOperation";
export default {
    name: "procurement",
    components: { importExcelModal },
    mixins:[toggleTableOperation],
    data() {
        return {
            timerId:null,
            companyList: [],
            backupList: [],
            shelfList: [],
            formItem: {
                contractNo: "",
                purchaseOrderNo: "",
                companyId: null,
                warehouseId: null,
                materielNo: "",
                goodsName: "",
                specification: "",
                sparePartsABC: "",
                sparePartsVED: "",
                goodsTypeStr: "",
                assetTypeStr: "",
                manageTypeStr: "",
                purchaseCount: null,
                purchasePrice: null,
                purchaseAmount: null,
                purchaseDate: "",
                purchasingAgent: null,
            },
            addtitle: "",
            allCheck: false,
            loading: false,
            searchParams: {},
            pageNum: 1,
            pageSize: 10,
            total: 0,
            dataArr: [],
            delFaultCodeShowF: false,//是否显示删除弹窗
            pageSizeOption: [10, 20, 30, 40],
            delIds: [],
            selection: [],
            checkBtnPermission: {},
            createByOptions: [],
            backupId: '',
            importExcelState: false, /*批量导入*/

            searchBackupList: [],
            addBackupList: [],
            locationList: [
                {
                    list: []
                }
            ],

            setFileList: [],
            materielsList: [],
            formAddObj: {
                purchaseCount: 0,
                purchasePrice: 0,
                purchaseAmount: 0,
            },
            addObj: {},
            procurementAddList: [
                {
                    backupConfigId: null,
                    shelfId: null,
                    locationId: null,
                    inputCount: 0,
                    assetsNo: '',
                }
            ],
            create: false,
            addModel: false,

            pageNumModel: 1,
            pageSizeModel: 10,
            totalModel: 0,
            pageSizeOptionModel: [10, 20, 30, 40],
            sparePartsAbcList: [{
                value: 'A',
                label: 'A类'
            }, {
                value: 'B',
                label: 'B类'
            }, {
                value: 'C',
                label: 'C类'
            },
            ],
            sparePartsVedList: [{
                value: 'V',
                label: 'V类'
            }, {
                value: 'E',
                label: 'E类'
            }, {
                value: 'D',
                label: 'D类'
            },
            ],
            goodsType: [{
                label: '1',
                value: '机械类'
            }, {
                label: '2',
                value: '气动类'
            }, {
                label: '3',
                value: '电气类'
            },
            ],
            assetType: [{
                label: '1',
                value: '资产类'
            }, {
                label: '2',
                value: '非资产类'
            },

            ],
            manageType: [{
                value: 1,
                label: '单个管理'
            },
            {
                value: 2,
                label: '批量管理'
            },
            ],
            orderStatus: [
                {
                    label: '0',
                    value: '未完成'
                },
                {
                    label: '1',
                    value: '已完成'
                },
            ],
            columns: [
                {
                    key: 'selection',
                    type: 'selection',
                    width: 60,
                    align: 'center'
                },
                {
                    //  title: '订单状态',
                    title: `${this.$t('spareParts.OrderStatus')}`,
                    key: 'orderStatusStr',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                    // render: (h, params) => {
                    //     return h('div', params.row.orderStatus === '0' ? '未完成' : params.row.orderStatus === '1' ? '已完成' : '')
                    // }
                },
                {
                    // title: '合同编号',
                    title: `${this.$t('spareParts.ContractNo')}`,
                    key: 'contractNo',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: '采购订单号',
                    title: `${this.$t('preliminary.PurchasingOrderNumber')}`,
                    key: 'purchaseOrderNo',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: `${this.$t('spareParts.company')}`,
                    title: `${this.$t('spareParts.company')}`,
                    key: 'companyName',
                    minWidth: 150,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: `${this.$t('spareParts.Warehouse')}`,
                    title: `${this.$t('spareParts.Warehouse')}`,
                    key: 'warehouseName',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: `${this.$t('spareParts.PartNo')}`,
                    title: `${this.$t('spareParts.PartNo')}`,
                    key: 'materielNo',
                    minWidth: 100,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: '品名',
                    title: `${this.$t('spareParts.Name')}`,
                    key: 'goodsName',
                    minWidth: 160,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: '规格',
                    title: `${this.$t('spareParts.Specification')}`,
                    key: 'specification',
                    minWidth: 140,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: '备件ABC类',
                    title: `${this.$t('spareParts.SparePartABC')}`,
                    key: 'sparePartsABC',
                    minWidth: 160,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: '备件VED类',
                    title: `${this.$t('spareParts.SparePartVED')}`,
                    key: 'sparePartsVED',
                    minWidth: 160,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: '物品分类',
                    title: `${this.$t('spareParts.ObjectClassification')}`,
                    key: 'goodsTypeStr',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: '资产类型',
                    title: `${this.$t('spareParts.AssetType')}`,
                    key: 'assetTypeStr',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: `${this.$t('common.ControlMode')}`,
                    title: `${this.$t('spareParts.ControlMode')}`,
                    key: 'manageTypeStr',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: '采购数量',
                    title: `${this.$t('spareParts.PurchasingQuantity')}`,
                    key: 'purchaseCount',
                    minWidth: 180,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: '采购单价',
                    title: `${this.$t('spareParts.UnitPrice')}`,
                    key: 'purchasePrice',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: '采购总价',
                    title: `${this.$t('spareParts.GrossPrice')}`,
                    key: 'purchaseAmount',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: '已入库数量',
                    title: `${this.$t('spareParts.InStorage')}`,
                    key: 'amountOfReceived',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: '待入库数量',
                    title: `${this.$t('spareParts.ToBeStored')}`,
                    key: 'amountOfToBeReceived',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: '采购员',
                    title: `${this.$t('spareParts.Buyer')}`,
                    key: 'purchasingAgent',
                    minWidth: 120,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: '下单时间',
                    title: `${this.$t('spareParts.OrderingTime')}`,
                    key: 'orderDate',
                    minWidth: 180,
                    align: 'center',
                    resizable: true
                },
                //操作
                {
                    title: `${this.$t('common.operation')}`,
                    key: 'action',
                    align: 'center',
                    fixed: 'right',
                    minWidth: this.util.autoWidth(320,350),
                    slot: 'action'
                }],
            infoAddcolumns: [
                {
                    // title: `${this.$t('spareParts.Warehouse')}`,
                    title: `${this.$t('spareParts.Warehouse')}`,
                    key: 'warehouseName',
                    minWidth: 100,
                    align: 'center',
                },
                {
                    // title: `${this.$t('spareParts.Rack')}`,
                    title: `${this.$t('spareParts.Rack')}`,
                    key: 'shelfName',
                    minWidth: 100,
                    align: 'center'
                },
                {
                    // title: `${this.$t('spareParts.Location')}`,
                    title: `${this.$t('spareParts.Location')}`,
                    key: 'locationName',
                    minWidth: 100,
                    align: 'center'
                },
                {
                    //title: '入库数量',
                    title: `${this.$t('spareParts.NumberOfStorage')}`,
                    key: 'inputCount',
                    minWidth: 100,
                    align: 'center'
                },
                //          {
                //   title: `${ this.$t('common.operation') }`,
                //   key: 'action',
                //   align: 'center',
                //   slot: 'action'
                // }
            ],
            infoColumns: [
                {
                    // title: `${this.$t('common.SpareNumber')}`,
                    title: `${this.$t('common.SpareNumber')}`,
                    key: 'backupNo',
                    minWidth: 100,
                    align: 'center',
                    resizable: true
                },
                {
                    //title: `${this.$t('spareParts.Warehouse')}`,
                    title: `${this.$t('spareParts.Warehouse')}`,
                    key: 'warehouseName',
                    minWidth: 100,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: `${this.$t('spareParts.Rack')}`,
                    title: `${this.$t('spareParts.Rack')}`,
                    key: 'shelfName',
                    minWidth: 100,
                    align: 'center',
                    resizable: true
                },
                {
                    // title: `${this.$t('spareParts.Location')}`,
                    title: `${this.$t('spareParts.Location')}`,
                    key: 'locationName',
                    minWidth: 100,
                    align: 'center',
                    resizable: true

                },
                {
                    // title: `${this.$t('spareParts.quantity')}`,
                    title: `${this.$t('spareParts.quantity')}`,
                    key: 'inputCount',
                    minWidth: 100,
                    align: 'center',
                    resizable: true
                }
            ],
            infoDataArr: [],

            itemBackupConfigId: null,
            queryMaterielsList:[],
            ruleValidate: {
                contractNo: [
                    { required: true, message: '请填写合同编号', trigger: 'change', type: 'string' }
                ],
                purchaseOrderNo: [
                    { required: true, message: '请填写采购订单号', trigger: 'blur', type: 'string' }
                ],
                companyId: [
                    { required: true, message: '请选择公司名称', trigger: 'change', type: 'number' }
                ],
                warehouseId: [
                    { required: true, message: '请选择仓库', trigger: 'change', type: 'number' }
                ],
                materielNo: [
                    { required: true, message: '请选择料号', trigger: 'change', type: 'string' }
                ],
                goodsName: [
                    { required: true, message: '请填写品名', trigger: 'blur', type: 'string' }
                ],
                specification: [
                    { required: true, message: '请填写规格', trigger: 'blur', type: 'string' }
                ],
                sparePartsABC: [
                    { required: true, message: '请选择备件ABC类', trigger: 'change', type: 'string' }
                ],
                sparePartsVED: [
                    { required: true, message: '请选择备件VED类', trigger: 'change', type: 'string' }
                ],
                goodsTypeStr: [
                    { required: true, message: '请填写物品分类', trigger: 'blur', type: 'string' }
                ],
                assetTypeStr: [
                    { required: true, message: '请填写资产类型', trigger: 'blur', type: 'string' }
                ],

                manageTypeStr: [
                    { required: true, message: '请填写管理方式', trigger: 'blur', type: 'string' }
                ],
                purchaseCount: [
                    { required: true, message: '请填写采购数量', trigger: 'blur', type: 'number' }
                ],
                purchasePrice: [
                    { required: true, message: '请选择采购单价', trigger: 'change', type: 'number' }
                ],
                purchaseAmount: [
                    { required: true, message: '请选择采购总价', trigger: 'change', type: 'number' }
                ],
                // purchaseDate: [
                //     { required: true, message: '请选择下单日期', trigger: 'change', type: 'date' }
                // ],
                purchasingAgent: [
                    { required: true, message: '请选择采购人员', trigger: 'change', type: 'number' }
                ],
            }
        }
    },
    created() {
        this.getColumnWidth(this.infoColumns,'attachmentProcurementProcurement')
        console.log(JSON.stringify(this.infoColumns))
    },
    mounted() {

        this.getTableColumnsWidth(this.columns)

        this.searchList();
        this.getCompanyList();
        this.getUserList();
        this.getMaterielsList();
        let itemList = JSON.parse(window.localStorage.getItem('USER_URI'))
        for (let item of itemList) {
            if (item.code == "purchaseList") {
                this.checkBtnPermission.purchaseList = true
            }
            if (item.code == "purchaseAdd") {
                this.checkBtnPermission.purchaseAdd = true
            }
            if (item.code == "purchaseDelete") {
                this.checkBtnPermission.purchaseDelete = true
            }
            if (item.code == "beputinstorageAdd") {
                this.checkBtnPermission.beputinstorageAdd = true
            }
            if (item.code == "purchaseGetInfo") {
                this.checkBtnPermission.purchaseGetInfo = true
            }
            if (item.code == "purchaseExport") {
                this.checkBtnPermission.purchaseExport = true
            }
            if (item.code == "purchaseImport") {
                this.checkBtnPermission.purchaseImport = true
            }
            if (item.code == "purchaseTemplate") {
                this.checkBtnPermission.purchaseTemplate = true
            }
        }

    },
    methods: {
      debounceSerach(fn, delay){
        let _this = this
        return function f(...args) {
          if (_this.timeID) {
            clearTimeout(_this.timeID);
          }
          _this.timeID = setTimeout(() => {
            fn(args);
          }, delay);
        };
      },
      purchasePriceChange(val){
        if (!val){
          return
        }
        const fn = this.debounceSerach(()=>{
          if (this.formAddObj.purchaseCount){
            this.formAddObj.purchaseAmount = this.formAddObj.purchaseCount * val
          }
        },300)
        fn()
      },
      purchaseCountChange(val){
        if (!val){
          return
        }
        const fn = this.debounceSerach(()=>{
          if (this.formAddObj.purchasePrice){
            this.formAddObj.purchaseAmount = this.formAddObj.purchasePrice * val
          }
        },300)
        fn()
      },
      assetsNochange(val){
        if (this.timerId) {
          clearTimeout(this.timerId)
        }
        const params = {
          assetsNo:val.assetsNo
        }
        this.timerId = setTimeout(() => {
          this.axios({
            method: 'get',
            url: '/dms/backup/beputinstorage/checkAssetsNo',
            params
          }).then(res => {
            if (res.code === 200) {
              if (!res.data){
                 this.$set(val,'assetsNo','')
              }
            } else {
              this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
            }
          })
        }, 600)
      },
        //获取公司
        getCompanyList() {
            getCompany().then(res => {
                if (res.code === 200) {
                    this.companyList = res.data
                } else {
                    this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                }
            }).finally(() => {
                this.loading = false
            })
        },

        //获取仓库
        getBackupList(data, type) {
            // if(!this.searchParams.companyId){
            //     this.$Message.warning(({ content:"请先选择公司", duration: 6, closable: true }));
            //     return false;
            // }
            let params = {
                companyId: data
            }

            getBackup(params, type).then(res => {
                if (res.code === 200) {
                    // this.backupList=  res.data
                    switch (type) {
                        case 1:
                            this.searchBackupList = res.data
                            break;
                        case 2:
                            this.addBackupList = res.data
                            break;
                        case 3:
                            this.backupList = res.data
                            break;
                        default:
                            this.backupList = ""
                            break;
                    }
                }
                // else {
                //     this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                // }
            }).finally(() => {
                this.loading = false
            })

            console.log("this.searchBackupList---1", this.searchBackupList)
            console.log("this.addBackupList---2", this.addBackupList)
        },
        //获取货架
        getShelfList(data) {

            console.log('procurementAddList----3', this.procurementAddList)
            // if(!this.searchParams.backup){
            //     this.$Message.warning(({ content:"请先选择仓库", duration: 6, closable: true }));
            //     return false;
            // }

            let params = {}
            params.delIds = []
            params.delIds.push(data)
            getShelf(params).then(res => {
                if (res.code === 200) {
                    this.shelfList = res.data
                } else {
                    this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                }
            }).finally(() => {
                this.loading = false
            })
        },
        //获取库位
        getLocationList(data, index) {
            // if(!this.searchParams.shelf){
            //     this.$Message.warning(({ content:"请先选择货架", duration: 6, closable: true }));
            //     return false;
            // }

  this.procurementAddList[index].locationId=null
            if(data){
            let params = {}
            params.delIds = []
            params.delIds.push(data)
            getLocation(params).then(res => {
                if (res.code === 200) {
                    this.locationList[index].list = res.data
                } else {
                     this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                }
            }).finally(() => {
                this.loading = false
            })
            console.log("locationList", this.locationList)
            }else{
                  this.locationList[index].list =[]
            }
        },
        //获取管理员
        getUserList() {
            getUserSelect().then(res => {
                if (res.code === 200) {
                    this.createByOptions = res.data.map(item => {
                        return {
                            ...item,
                            showName: item.empno + '----' + item.username
                        }
                    })
                } else {
                    this.createByOptions = []
                    this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                }
            }).finally(() => {
                this.loading = false
            })
        },
        // 获取料号
        getMaterielsList(query) {
            let params = {}
            getMateriels({value:query}).then(res => {
                if (res.code === 200) {
                    this.materielsList = res.data;
                } else {
                    this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                }
            })
        },
      // 获取料号
      getQueryMaterielsList(query) {
        getMateriels({value:query}).then(res => {
          if (res.code === 200) {
            this.queryMaterielsList = res.data;
          } else {
            this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
          }
        })
      },
        //料号
        handleChange(val) {
            this.queryMaterielsList.forEach(item => {
                if (item.materielNo === val) {
                    this.addObj.goodsName = item.goodsName
                    this.addObj.specification = item.specification
                    this.addObj.sparePartsABC = item.sparePartsAbcName
                    this.addObj.sparePartsVED = item.sparePartsVedName
                    this.addObj.goodsTypeStr = item.goodsTypeName
                    this.addObj.assetTypeStr = item.assetTypeName
                    this.addObj.manageTypeStr = item.manageTypeName
                }
            });
        },
      reset(){
        this.searchParams = {};
        this.searchParams.dateVal = [];
        this.changeNum();
      },
        //分页
        changeNum() {
            this.pageNum = 1;
            this.searchList();
        },
        changePageSize(pageSize) {
            this.pageSize = pageSize;
            this.searchList();
        },
        changePageNum(val) {
            this.pageNum = val;
            this.searchList();
        },
        changeNumModel() {
            this.pageNumModel = 1;
            this.getInfo();
        },
        changePageSizeModel(pageSize) {
            this.pageSizeModel = pageSize;
            this.getInfo();
        },
        changePageNumModel(val) {
            this.pageNumModel = val;
            this.getInfo();
        },
        //查询列表
        searchList() {
            let params = {
                pageNum: this.pageNum,
                pageSize: this.pageSize,
                warehouseId: this.backupId,
            };
            for (let key in this.searchParams) {
                if (this.searchParams[key]) {
                    this.$set(params, key, this.searchParams[key])
                }
            }
            searchApi(params).then(res => {
                
                if (res.code === 200) {
                    this.dataArr = res.data.list
                    this.total = res.data.total
                } else {
                    this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                }
            })
        },
        //查看
        lockClick(record) {
            this.$router.push({
                path: '/spareParts/attachmentProcurement/detailPurchaseModal',
                query: {
                    requestNo: record.banfn,
                    requestProject: record.bnfpo,
                    orderNo: record.ebeln,
                    orderProject: record.ebelp,
                    werksName: record.werksName,
                    id: record.id,
                }
            })
        },
        //添加入库信息
        handleAdd() {
            this.procurementAddList.push({
                backupConfigId: this.itemBackupConfigId,
                shelfId: null,
                locationId: null,
                inputCount: 0,
            })
            this.locationList.push({ list: [] })

        },
        //添加入库信息
        handleDelete(id) {
            this.procurementAddList = this.procurementAddList.filter((item, index) => id != index)
        },
        //新增
        handelAdd() {

           this.addtitle = `${this.$t('common.New')}`
            this.formAddObj = {
                purchaseCount: 0,
                purchasePrice: 0,
                purchaseAmount: 0,
                purchasingAgent:Number(localStorage.getItem('ziyunFactoryUserId'))
            };
            this.addObj = {}
            this.setFileList = [];
            this.addModel = true;
        },
        //入库
        createfaultCodeShowH(row) {
            // this.$refs.form.resetFields();
            //this.getBackupList(row.companyName,3)
            this.procurementAddList = [
                {
                    backupConfigId: null,
                    shelfId: null,
                    locationId: null,
                    inputCount: 0,
                }
            ],
                this.getBackupList(row.companyId, 3)
            this.getInfo(row.id)
            if (row.id) {
                this.addtitle = `${this.$t('spareParts.Putaway')}`
                this.formItem.id = row.id
                this.formItem.companyId = row.companyId
                this.formItem.materielNo = row.materielNo
                this.formItem.backupPurchaseId = row.id
                this.formItem.purchaseCount = row.purchaseCount
                this.formItem.amountOfReceived = row.amountOfReceived
                this.formItem.amountOfToBeReceived = row.amountOfToBeReceived
                this.procurementAddList.map(item => {
                    item.backupConfigId = Number(row.backupConfigId)
                })
                this.itemBackupConfigId = Number(row.backupConfigId)
                // this.formItem.backupName=row.backupName
                //  this.formItem.manageBy=row.manageBy
                //  this.formItem.remark=row.remark


            }
            this.getShelfList(this.itemBackupConfigId)

            // this.getColumnWidth(this.infoColumns,'attachmentProcurementProcurement')
            this.create = true;
        },
        addYes(name) {
          if (!this.formAddObj.purchaseDate){
            this.$Message.warning(({content:"请选择下单日期",duration:6,closable:true}));
            return
          }
            this.formAddObj.attachments = this.setFileList
            this.formAddObj.purchaseDate = moment(this.formAddObj.purchaseDate).format('YYYY-MM-DD HH:mm:ss');

          if (this.formAddObj.workOrderNo){
            if (!this.formAddObj.arrivalDate){
              this.$Message.warning(({content:"请选择到位日期",duration:6,closable:true}));
              return
            }else{
              this.formAddObj.arrivalDate = moment(this.formAddObj.arrivalDate).format('YYYY-MM-DD HH:mm:ss');
            }
          }


            this.$refs[name].validate((valid) => {
                if (valid) {
                  addApi(this.formAddObj).then(res => {
                    this.loading = false;
                    if (res.code === 200) {
                      this.changeNum();
                      this.$Message.success("新增成功");
                      this.addModel = false;
                    } else {
                      this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                    }
                  })
                }
            })
            //this.$refs.addModel.resetFields();
        },
        addOk(name) {
            this.$refs[name].validate((valid) => {
                if (!valid) {
                    return
                } else {
                    this.loading = true;
                    let ziyunFactoryUserId = window.localStorage.getItem('ziyunFactoryUserId')
                    if (this.procurementAddList.length > 0) {
                        this.procurementAddList = this.procurementAddList.map(item => {
                            return {
                                ...item,
                                backupPurchaseId: this.formItem.backupPurchaseId,
                                materielNo: this.formItem.materielNo,
                                putInStorageBy: Number(ziyunFactoryUserId)
                            }
                        })
                    }
                    // params.push(this.procurementAddList)
                    enterApi(this.procurementAddList).then(res => {
                        this.loading = false; 0
                        if (res.code === 200) {
                            this.changeNum();
                            this.$Message.success("入库成功");
                            this.create = false;
                        } else {
                            this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                        }
                    })
                }
            })

        },
        timeOnChange(value) {
            this.searchParams.dateVal = value;
            this.searchParams.orderDateStart = value[0]
            this.searchParams.orderDateEnd = value[1]
        },

        //入库列表
        getInfo(id) {
            let params = {
                pageNum: this.pageNumModel,
                pageSize: this.pageSizeModel,
                purchaseId: id
            };
            infoBeputinstorageApi(params).then(res => {
                if (res.code === 200) {
                    this.infoDataArr = res.data.list
                    this.totalModel = res.data.total
                    // this.dataSource = res.data.dmsDeliveryList
                    // this.detailObj.dmsDeliveryList.forEach(item => {
                    //     item.menge = res.data.menge
                    // });

                } else {
                    this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                }
            })
        },
        //勾选列表
        onSelectChange(selection) {
            let myArray = [];
            selection.map((item, index) => {
                myArray.push(item.id);
            });
            this.delIds = myArray;
            if (selection.length > 0) {
                this.allCheck = true;
            } else {
                this.allCheck = false;
            }
        },
        //批量删除
        delFaultCodeShowClick() {
            if (this.delIds.length == 0) {
                this.$Message.warning({
                    content:`${ this.$t('common.deleteItems') }`,
                    duration: 6,
                    closable: true,
                });
                return;
            } else {
                this.delFaultCodeShowF = true;
            }
        },
        //删除
        delPrrShowH(row) {
            //点击展示提示删除弹窗
            this.delFaultCodeShowF = true;
            this.delIds = [];
            this.delIds.push(row.id);
        },
        deleteOk() {
            this.loading = true;
            let params = { purchaseIds: this.delIds + "" }
            deleteApi(params).then(res => {
                this.loading = false;
                if (res.code === 200) {
                    this.changeNum();
                    this.$Message.success("删除成功");
                    this.allCheck = false;
                    this.delFaultCodeShowF = false;
                } else {
                    this.$Message.warning(({ content: res.msg, duration: 6, closable: true }));
                }
            })
        },
        //下载模板
        exportTemplate() {
            const filName = '备品采购配置模板'
            templateApi().then(res => {
                fileDownload(res, filName + '.xlsx')
            })
        },
        //导入
        importExcelShow() {
            this.importExcelState = true;
        },
        importExcelChange(val) {
            this.importExcelState = false;
            if (val === 'success') {
                this.changeNum();
            }
        },
        //导出
        exportTemplateClick() {
            let params = {
                pageNum: this.pageNum,
                pageSize: this.pageSize,
                ids: this.delIds,
            };
            for (let key in this.searchParams) {
                if (this.searchParams[key]) {
                    this.$set(params, key, this.searchParams[key])
                }
            }
            const filName = '备件采购'
            exportApi(params).then(res => {
                fileDownload(res, filName + '.xlsx')
            })
        },
        //上传附件

        handleBeforeUpload(file) {
            let formData = new FormData();
            formData.append("dir", 'device')
            formData.append("file", file)
            let config = {
                headers: {
                    "Content-Type": "multipart/form-data"
                }
            };
            this.axios({
                method: 'post',
                url: '/fileServer/upload',
                data: formData,
                config,
            }).then(res => {
                if (res.code == 200) {

                  const {fileName,filepath,fileUrl,fileLength,suffix} = res.data;
                    this.setFileList.push({
                        fileName,
                        filePath: filepath,
                        fileUrl,
                        fileSize:fileLength,
                        suffix,
                        fileDocumentEnumPath:"BACKUP_PURCHASE_APPLY"
                    })
                }
            })
            return false;
        },
        //文件删除
        delFileList(id) {
            this.setFileList = this.setFileList.filter((item, index) => index != id)
        },
        //文件预览
        handlePreview(item) {
            if (item) {
                window.open(this.util.filePathToUrl(item.filePath))
            }
        },
        cancel(){
            this.addModel = false
             this.$refs.addForm.resetFields();

        },
    }
}
</script>

<style scoped lang="scss">
/deep/.ivu-input-number{
  width: 100% !important;
}
.zy-content {
    .formList {
        padding: 0 40px
    }

    .createModal {
        padding: 0 20px;

        .table {
            margin: 10px 0;
        }
    }

    .pr {
        margin-right: 10px;
    }

    //margin-top:100px;
    .addContenrt {
        margin-top: 40px;

        .red {
            color: red
        }
    }


    .ivu-input-number {
        width: -webkit-fill-available;
    }

    .tableContent {
        padding-bottom: 40px;
    }

    .addModel {
        .item-src {
            cursor: pointer;
        }

    }
}
</style>

<style scoped lang="scss">
/deep/.ivu-upload-drag:hover {
    border: none !important;
}

/deep/.ivu-upload-drag {
    border: none !important;
}
</style>

